/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2010
Version 0.1
=======================================================*/
#ifndef __ACSERVER_H__
#define __ACSERVER_H__

#include <map>
#include <fstream>
#include <iostream>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread/mutex.hpp>
#include <rgcpp/utils/LogHandler.h>
#include <rgcpp/structs/Singleton.h>

namespace acs
{

class ACServer : public rgcpp::Singleton<ACServer>
{
	friend class rgcpp::Singleton<ACServer>;

	private:
		bool daemon;
		static bool shutdown;

	public:
		~ACServer();

		void start();
		void stop();
		void restart();
		void printStatus();

		bool isDaemon() const;

		static void sendStopSignal();
		static void sendRestartSignal();
		static void sendStatusSignal();

		static void installSignalHandlers();
		static void signalHandler(int signal);

	private:
		ACServer(bool aDaemon=false);

		void goDaemon();

		static pid_t readPid();
};

}

#endif

